package com.cskaoyan.javase.oop2._2polymorphic._2advantage;
/**
 * 探究向下转型的成功条件
 * 成功的条件是:
 * 成功的前提：
 *      父类引用指向的真实对象的类型，就是要强转成的子类类型的对象或者子类对象。
 *      父类引用指向的对象
 *          确实能够被强转后引用指向
 *
 * @since 11:11
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo3 {
    public static void main(String[] args) {
        Grandfather gf = new Grandson();
        Father f = (Father) gf;
        Son s = (Son) gf;
        Grandson gs = (Grandson) gf;
    }
}
class Grandfather{}
class Father extends Grandfather{}
class Son extends Father{}
class Grandson extends Son{}
